#include <iostream>
using namespace std;

signed main()
{
    int n;
    cin>>n;
    int f0 = 0,f1 = 1;
    while(f1<=n){
        int t = f1;
        f1 += f0;
        f0 = t;
    }
    if(f1-n<n-f0)    cout<<f1;
    else    cout<<f0;
    return 0;
}
